{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import math\n",
    "\n",
    "class Point:\n",
    "    def __init__(self, x, y):\n",
    "        self.__x = x\n",
    "        self.__y = y\n",
    "\n",
    "    @property\n",
    "    def x(self):\n",
    "        return self.__x\n",
    "\n",
    "    @x.setter\n",
    "    def x(self, value):\n",
    "        self.__x = value\n",
    "\n",
    "    @property\n",
    "    def y(self):\n",
    "        return self.__y\n",
    "\n",
    "    @y.setter\n",
    "    def y(self, value):\n",
    "        self.__y = value\n",
    "\n",
    "    def __str__(self):\n",
    "        return f\"Point({self.__x}, {self.__y})\"\n",
    "\n",
    "    def __add__(self, other):\n",
    "        self.x += other.x\n",
    "        self.y += other.y\n",
    "        return self\n",
    "\n",
    "    def __eq__(self, other):\n",
    "        return self.x == other.x and self.y == other.y\n",
    "\n",
    "    def getDistance(self, other):\n",
    "        w = self.__x - other.__x\n",
    "        h = self.__y - other.__y\n",
    "        return math.sqrt(w**2 + h**2)\n",
    "\n",
    "class Circle:\n",
    "    def __init__(self, o, r):\n",
    "        self.o = o\n",
    "        self.r = r\n",
    "\n",
    "    def __str__(self):\n",
    "        return f\"Circle({self.o}, {self.r})\"\n",
    "\n",
    "    def getArea(self):\n",
    "        return math.pi * self.r**2\n",
    "\n",
    "    def getPerimeter(self):\n",
    "        return math.pi * self.r * 2\n",
    "\n",
    "class Point3D:\n",
    "    def __init__(self, x, y, z):\n",
    "        self.x = x\n",
    "        self.y = y\n",
    "        self.z = z\n",
    "\n",
    "    def __str__(self):\n",
    "        return f\"Point3D({self.x}, {self.y}, {self.z})\"\n",
    "\n",
    "    def getDistance(self, other):\n",
    "        w = self.x - other.x\n",
    "        h = self.y - other.y\n",
    "        z = self.z - self.z\n",
    "        return math.sqrt(w**2 + h**2 + z**2)\n",
    "\n",
    "class Sphere(Point3D):\n",
    "    def __init__(self, r, x, y, z):\n",
    "        super().__init__(x, y, z)\n",
    "        self.r = r\n",
    "\n",
    "    def __str__(self):\n",
    "        return f\"Sphere({super().__str__()}, {self.r})\"\n",
    "\n",
    "    def getArea(self):\n",
    "        return math.pi * self.r**2 * 4\n",
    "\n",
    "    def getVolume(self):\n",
    "        return math.pi * self.r**3 * 4 / 3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Point(7, 10)\n"
     ]
    }
   ],
   "source": [
    "p1 = Point(2, 3)\n",
    "p2 = Point(5, 7)\n",
    "\n",
    "p3 = p1 + p2\n",
    "print(p3)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True\n"
     ]
    }
   ],
   "source": [
    "p1 = Point(2, 3)\n",
    "p2 = Point(2, 3)\n",
    "print(p1 == p2)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}